package 笔试.美团.第二题小团的选调计划;

import java.util.*;
import java.util.concurrent.ThreadPoolExecutor;

public class Main
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
//        int n=sc.nextInt();
//        int[][] arr=new int[n][n];
        int n=4;
        int[][] arr={{1,5,3,4,2},{2,3,5,4,1},{5,4,1,2,3},{1,2,5,4,3}};
//        for (int i = 0; i < n; i++)
//        {
//            int[] ints = new int[n];
//            for (int j = 0; j < n; j++)
//            {
//                ints[j]=sc.nextInt();
//            }
//            arr[i]=ints;
//        }
        LinkedHashSet<Integer> res = new LinkedHashSet<>();
        int i=0;
        int j=0;
        while (res.size()<n)
        {
            while (res.contains(arr[i][j]))
            {
                j++;
            }
            if (!res.contains(arr[i][j]))
            {
                res.add(arr[i][j]);
                i++;
            }
        }
        for (Iterator<Integer> it = res.iterator(); it.hasNext(); )
        {
            Integer r = it.next();
            System.out.print(r+" ");
        }

    }
}
